<?php
/**
 * Controller is the customized base controller class.
 * All controller classes for this application should extend from this base class.
 */
class Controller extends CController
{
	/**
	 * @var string the default layout for the controller view. Defaults to 'column1',
	 * meaning using a single column layout. See 'protected/views/layouts/column1.php'.
	 */
	public $layout='layout1';

	public $defaultAction = 'index';
	/**
	 * @var array context menu items. This property will be assigned to {@link CMenu::items}.
	 */
	public $menu=array(
					array('label'=>'发现', 'url'=>array('/news'),'linkOptions'=>array('class'=>'turn1'),'itemOptions'=>array('class'=>'nav_left')),
					array('label'=>'赞友', 'url'=>array('/upper'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_mid')),
					array('label'=>'收藏', 'url'=>array('/favorites'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_right')),
				);
	/**
	 * @var array the breadcrumbs of the current page. The value of this property will
	 * be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
	 * for more details on how to specify this property.
	 */
	public $breadcrumbs=array();
	public $isGuest = false;
	public function init(){
		$controller = $this->id;
		$this->isGuest = Yii::app()->user->isGuest;
		//Yii::app()->clientScript->registerCssFile('/css/sign.css');
		//Yii::app()->clientScript->registerCssFile('/css/olduser_login.css');
		//Yii::app()->clientScript->registerCssFile('/css/base.css');
		//Yii::app()->clientScript->registerCssFile('/css/reset.css');
		
		switch($controller){
			case 'news':
				if(!$this->isGuest)
					$this->menu=array(
						array('label'=>'发现', 'url'=>array('/news'),'linkOptions'=>array('class'=>'turn1'),'itemOptions'=>array('class'=>'nav_left')),
						array('label'=>'赞友', 'url'=>array('/upper'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_mid')),
						array('label'=>'收藏', 'url'=>array('/favorites'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_right')),
					);
				//Yii::app()->clientScript->registerCssFile('/css/logined.css');
				//Yii::app()->clientScript->registerCssFile('/css/news.css');
			break;
			case 'upper':
				if(!$this->isGuest)
				$this->menu=array(
					array('label'=>'发现', 'url'=>array('/news'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_left')),
					array('label'=>'赞友', 'url'=>array('/upper'),'linkOptions'=>array('class'=>'turn1'),'itemOptions'=>array('class'=>'nav_mid')),
					array('label'=>'收藏', 'url'=>array('/favorites'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_right')),
				);
				else
				$this->menu=array(
					array('label'=>'发现', 'url'=>array('/news'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_left')),
					array('label'=>'赞友', 'url'=>array('/upper'),'linkOptions'=>array('class'=>'turn1'),'itemOptions'=>array('class'=>'nav_mid')),
				);

				//Yii::app()->clientScript->registerCssFile('/css/zanyou.css');
				//Yii::app()->clientScript->registerCssFile('/css/logined.css');
				//Yii::app()->clientScript->registerCssFile('/css/conllection.css');
			break;
			case 'fans':
				if(!$this->isGuest)
				$this->menu=array(
					array('label'=>'发现', 'url'=>array('/news'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_left')),
					array('label'=>'赞友', 'url'=>array('/upper'),'linkOptions'=>array('class'=>'turn1'),'itemOptions'=>array('class'=>'nav_mid')),
					array('label'=>'收藏', 'url'=>array('/favorites'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_right')),
				);
				//Yii::app()->clientScript->registerCssFile('/css/zanyou.css');
			break;
			case 'favorites':
				if(!$this->isGuest)
				$this->menu=array(
					array('label'=>'发现', 'url'=>array('/news'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_left')),
					array('label'=>'赞友', 'url'=>array('/upper'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_mid')),
					array('label'=>'收藏', 'url'=>array('/favorites'),'linkOptions'=>array('class'=>'turn1'),'itemOptions'=>array('class'=>'nav_right')),
				);
				//Yii::app()->clientScript->registerCssFile('/css/logined.css');
				//Yii::app()->clientScript->registerCssFile('/css/conllection.css');
			break;
			case 'account':
				if(!$this->isGuest)
				$this->menu=array(
					array('label'=>'发现', 'url'=>array('/news'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_left')),
					array('label'=>'赞友', 'url'=>array('/upper'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_mid')),
					array('label'=>'收藏', 'url'=>array('/favorites'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_right')),
				);
				else
				$this->menu=array(
					array('label'=>'发现', 'url'=>array('/news'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_left')),
					array('label'=>'赞友', 'url'=>array('/upper'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_mid')),
					array('label'=>'收藏', 'url'=>array('/favorites'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_right')),
				);
			break;
			case 'tag':
				if(!$this->isGuest)
				$this->menu=array(
					array('label'=>'发现', 'url'=>array('/news'),'linkOptions'=>array('class'=>'turn1'),'itemOptions'=>array('class'=>'nav_left')),
					array('label'=>'赞友', 'url'=>array('/upper'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_mid')),
					array('label'=>'收藏', 'url'=>array('/favorites'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_right')),
				);
				//Yii::app()->clientScript->registerCssFile('/css/logined.css');
				break;
			case 'setting':
				$this->menu=array(
					array('label'=>'发现', 'url'=>array('/news'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_left')),
					array('label'=>'赞友', 'url'=>array('/upper'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_mid')),
					array('label'=>'收藏', 'url'=>array('/favorites'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_right')),
				);
				//Yii::app()->clientScript->registerCssFile('/css/logined.css');
				//Yii::app()->clientScript->registerCssFile('/css/setting.css');
				break;
			case 'help':
				if(!$this->isGuest)
				$this->menu=array(
					array('label'=>'发现', 'url'=>array('/news'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_left')),
					array('label'=>'赞友', 'url'=>array('/upper'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_mid')),
					array('label'=>'收藏', 'url'=>array('/favorites'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_right')),
				);
				//Yii::app()->clientScript->registerCssFile('/css/zanyou.css');
				break;
			case 'search':
				if(!$this->isGuest)
				$this->menu=array(
					array('label'=>'发现', 'url'=>array('/news'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_left')),
					array('label'=>'赞友', 'url'=>array('/upper'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_mid')),
					array('label'=>'收藏', 'url'=>array('/favorites'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_right')),
				);
				//Yii::app()->clientScript->registerCssFile('/css/logined.css');
			case 'links':
				if(!$this->isGuest)
				$this->menu=array(
					array('label'=>'发现', 'url'=>array('/news'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_left')),
					array('label'=>'赞友', 'url'=>array('/upper'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_mid')),
					array('label'=>'收藏', 'url'=>array('/favorites'),'linkOptions'=>array('class'=>'turn2'),'itemOptions'=>array('class'=>'nav_right')),
				);
				//Yii::app()->clientScript->registerCssFile('/css/logined.css');

		}
		parent::init();
	}
}
